// 固定写法
export const state = function() {
  return {
    userInfo: {}
  };
};

export const mutations = {
  setUser(state, data) {
    state.userInfo = data;
  }
};

export const actions = {
 async login({ commit }, user) {
   const res =  await this.$axios({method: "post",url: "/accounts/login",data: user})
      // 登录成功的数据
      commit("setUser", res.data);
      return res;
  },
  register(store, props) {
    return this.$axios({
      url: `/accounts/register`,
      method: "POST",
      data: props
    }).then(res => {
      return res;
    });
  }
};
